package com.android.huimeiqupin.utils;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.Callback;
import java.util.Map;

/**
 * http请求类
 * Created by wzq on 2016/9/1.
 */
public class HttpUtils {

    /**
     * POST请求
     * 有请求头
     *
     * @param url
     * @param mHeaders
     * @param mParams
     * @param mCallback
     */
    public static void post(String url, Map<String, String> mHeaders, Map<String, String> mParams, Callback mCallback) {
        OkHttpUtils
                .post()
                .url(url)
                .headers(mHeaders)
                .params(mParams)
                .build()
                .execute(mCallback);
    }

    /**
     * POST请求
     * 无请求头
     *
     * @param url
     * @param mParams
     * @param mCallback
     */
    public static void post(String url, Map<String, String> mParams, Callback mCallback) {
        OkHttpUtils
                .post()
                .url(url)
                .params(mParams)
                .build()
                .execute(mCallback);
    }

    /**
     * GET请求
     * 有请求头
     *
     * @param url
     * @param mHeaders
     * @param mParams
     * @param mCallback
     */
    public static void get(String url, Map<String, String> mHeaders, Map<String, String> mParams, Callback mCallback) {
        OkHttpUtils
                .get()
                .url(url)
                .headers(mHeaders)
                .params(mParams)
                .build()
                .execute(mCallback);
    }

    /**
     * GET请求
     * 无请求头
     *
     * @param url
     * @param mParams
     * @param mCallback
     */
    public static void get(String url, Map<String, String> mParams, Callback mCallback) {
        OkHttpUtils
                .get()
                .url(url)
                .params(mParams)
                .build()
                .execute(mCallback);
    }
}
